package com.hedl.practice.diyJava.reflex.study_01.tmp;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Date;

public class NewInstanceTest {
    public static void main(String[] args) throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {

        Class c = Date.class;
        Date date = (Date) c.newInstance();
        System.out.println(date);

        long timestamp = date.getTime();
        Constructor constructor = c.getConstructor(long.class);
        Date date1 = (Date)constructor.newInstance(timestamp);
        System.out.println(date1);
    }
}
